package com.opesoft.app.system.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name="dictionary", uniqueConstraints=@UniqueConstraint(columnNames={"rank"}))
public class Dictionary
{
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE, generator="DictionaryIdGenerator")
	@TableGenerator(name="DictionaryIdGenerator", table="ids", pkColumnName="entity", valueColumnName="maxid", pkColumnValue="Dictionary", allocationSize=1)
	long id;

	@Basic
	String code; // 编码

	@Basic
	String name; // 名称

	@Basic
	String remark; // 说明信息

	@Basic
	Boolean active; // 是否可用

	@Basic
	long rank; // 排序的位置

	@Basic
	@Column(name="dictionary_config")
	Long dictionaryConfigId; // 所属的字典类别

	@ManyToOne(optional=true, fetch=FetchType.LAZY)
	@JoinColumn(name="dictionary_config", insertable=false, updatable=false)
	@ForeignKey(name="fk_dictionary1")
	DictionaryConfig dictionaryConfig;

	public long getId()
	{
		return id;
	}

	public void setId(long id)
	{
		this.id=id;
	}

	public long getRank()
	{
		return rank;
	}

	public void setRank(long rank)
	{
		this.rank=rank;
	}

	public String getCode()
	{
		return code;
	}

	public void setCode(String code)
	{
		this.code=code;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name=name;
	}

	public DictionaryConfig getDictionaryConfig()
	{
		return dictionaryConfig;
	}

	public void setDictionaryConfig(DictionaryConfig dictionaryConfig)
	{
		this.dictionaryConfig=dictionaryConfig;
	}

	public String getRemark()
	{
		return remark;
	}

	public void setRemark(String remark)
	{
		this.remark=remark;
	}

	public Long getDictionaryConfigId()
	{
		return dictionaryConfigId;
	}

	public void setDictionaryConfigId(Long dictionaryConfigId)
	{
		this.dictionaryConfigId=dictionaryConfigId;
	}

	public Boolean getActive()
	{
		return active;
	}

	public void setActive(Boolean active)
	{
		this.active=active;
	}

}
